package thread;

import java.util.Scanner;

/**
 * 用户输入一个倒计时，sleep方法间隔1秒每次输出倒计时减一，直到进程结束
 */
public class SleepDemo {
    public static void main(String[] args) {
        System.out.println("程序开始");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数字：");
        for (int i =scanner.nextInt(); i>0; i--) {
            System.out.println(i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("程序结束");
    }
}
